<?php
abstract class BaseModelLog {
    /**
     * protected log level type
     * @var mixed array
     */
    protected static $levels = array(
			LOG_WARNING => 'warning',
			LOG_NOTICE => 'notice',
			LOG_INFO => 'info',
			LOG_DEBUG => 'debug',
			LOG_ERROR => 'error'
	);
	/**
	 * regular the log type
	 * @param int $type
	 * @return string
	 */
	public static function getType($type) {
	    if (is_int($type) && isset(self::$levels[$type])) {
			$type = self::$levels[$type];
		}
		else {
		    $type = self::$levels[0];
		}
		return $type;
	} 
	/**
	 * abstract method, write the log
	 * @param string $msg
	 * @param int $type
	 * @return bool
	 */
    abstract public static function write($msg, $type = LOG_WARNING);
    /**
     * abstract method, read the sepcial type of log
     * @param int $type
     * @return string or false on failure
     */
    abstract public static function read($type = LOG_WARNING);
    /**
     * abstract method, truncate the type of log
     * @param int $type
     * @return bool
     */ 
    abstract public static function truncate($type = LOG_WARNING);
}